﻿using System;
using System.Collections.Generic;
using DynamicGeneration.Framework.DAL;
using MusicLine.BusinessEntities;
using System.Data;

namespace MusicLine.DAL
{
    class Album_DS<T> : AbstractDataStore where T : AlbumBase
    {
        #region Business Entity Hydration
        protected static void HydrateInfo(ref AbstractInfo objectToHydrate, IDataReader reader)
        {
            AssertInstance<T>(ref objectToHydrate);
            T info = (T)objectToHydrate;
            info.AlbumId = reader.GetInt32(reader.GetOrdinal("AlbumId"));
            info.ArtistId = reader.GetInt32(reader.GetOrdinal("ArtistId"));
            info.Title = reader.GetString(reader.GetOrdinal("Title"));
            info.LengthInSeconds = reader.GetInt32(reader.GetOrdinal("LengthInSeconds"));
        }
        private Hydrate Hydrator = new Hydrate(HydrateInfo);
        #endregion

        #region Create Methods
        #endregion

        #region Read Methods
        public IList<T> GetAllAlbums()
        {
            return FillList<T>(Hydrator, DataStore.ExecuteReader("ListAllAlbums"));
        }
        #endregion

        #region Update Methods
        #endregion

        #region Delete Methods
        #endregion
    }
}
